#coding:utf-8
from xlutils.copy import copy
from xlrd import open_workbook
from openpyxl import Workbook
import os
if not os.path.isfile("job_data.xls"):
        wb = Workbook()
        sheet1 = wb.active
        sheet1.append(["地点","搜索关键字","公司","职位","发布日期","链接地址"])

        wb.save("job_data.xls")
job_data = open_workbook(filename = "job_data.xls")
job_data_bak = copy(job_data)
sheet1 = job_data_bak.get_sheet(0)

item = {"updatetime": "04-24", "keyword": "HTML5开发", "title": "\r\n                                    HTML5开发助理+无经验可实习+五险一金                                ",
    "company": "北京优才创智科技有限公司", "link": "http://jobs.51job.com/shanghai-bsq/88421606.html?s=01&t=0", "location": "上海"}
row_data = [item['location'],item['keyword'],item['company'],item['title'].strip(),item['updatetime'],item['link']]
rows =  job_data.sheet_by_index(0).nrows
cols =  job_data.sheet_by_index(0).ncols
for col in range(0,cols):
    sheet1.write(rows,col,row_data[col].decode('utf-8'))

job_data_bak.save("job_data.xls")